<?php
/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */


/**
 * Smarty count modifier plugin
 *
 * Type:     modifier<br>
 * Name:     count<br>
 * Date:     09/12/12
 * Purpose:  count the number of elements in an array or the length of a string
 * Input:    objetc
 * Example:  {$var|count}
 * @version 1.0
 * @param object
 * @return int
 */

function smarty_function_count($params,&$smarty)
{
   $var  = $params['var'];
    $cnt = 0;
    if(is_array($var)){
      $cnt = count($var);
    } else if (is_string($var)){
      $cnt = strlen($var);
    }
  
    return $cnt;
}

/* vim: set expandtab: */

?>
